<template>
  <div class="cellphone">
    <el-dialog
      title="修改手机号"
      :visible.sync="changePhone"
      width="675px"
      :modal-append-to-body="true"
      center
    >
      <el-form ref="from" :model="form" label-position="left" :rules="rules" :hide-required-asterisk="true">
        <el-form-item label="当前手机号" :label-width="formLabelWidth">
          <span>132****0930</span>
        </el-form-item>
        <el-form-item label="输入密码" :label-width="formLabelWidth">
          <el-input
            v-model="form.pwd"
            type="password"
            autocomplete="off"
            placeholder="请输入正确的密码"
          />
        </el-form-item>
        <el-form-item label="新手机号" :label-width="formLabelWidth" prop="phone">
          <el-input
            v-model="form.phone"
            autocomplete="off"
            placeholder="请输入正确的手机号"
          />
        </el-form-item>
        <el-form-item label="输入验证码" :label-width="formLabelWidth">
          <el-input
            v-model="form.code"
            autocomplete="off"
            placeholder="请输入验证码"
          />
        </el-form-item>
        <el-button
          style="left: 513px;
            position: relative;
            top: -62px;"
        >
          获取验证码
        </el-button>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="changePhone = false; phone = true">确 定</el-button>
        <el-button @click="changePhone = false">返 回</el-button>
      </span>
    </el-dialog>
    <!-- 修改手机号完毕弹出框 -->
    <div class="pwd">
      <el-dialog
        :visible.sync="phone"
        width="675px"
        center
        style="text-agin:content"
      >
        <span>
          <i class="iconfont iconmerchants_icon_dui" />
          <p
            style="
            font-size:22px;
            line-height:42px;
            color:rgba(51,51,51,1);
            "
          >手机号更换成功！<br>请使用新的手机号重新登录
          </p>
        </span>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="phone = false">重新登陆</el-button>
        </span>
      </el-dialog>
    </div>
    <!-- /修改手机号完毕弹出框 -->
  </div>
</template>

<script>
export default {
  name: 'CellPhone',
  data() {
    var checkPhone = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('手机号不能为空'))
      } else {
        const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
        console.log(reg.test(value))
        if (reg.test(value)) {
          callback()
        } else {
          return callback(new Error('请输入正确的手机号'))
        }
      }
    }
    return {
      changePhone: false,
      phone: false,
      form: {
        pwd: '',
        phone: '',
        code: ''
      },
      formLabelWidth: '120px',
      rules: {
        phone: [
          { validator: checkPhone, trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    showCellPhone() {
      this.changePhone = true
    }
  }
}
</script>

<style lang='scss' scoped>
.cellphone {
  .el-dialog__body{
    text-align: center !important;
    span{
      .iconfont{
        font-size: 65px;
      }
    }
  }
  .el-dialog__footer{
    .el-button{
      width:170px;
      height:42px;
      background:rgba(65,122,239,1);
      border-radius:4px;
    }
    .el-button:nth-child(2) {
      width:170px;
      height:42px;
      // border:1px solid rgba(219,219,219,1);
      background: #fff;
      border-radius:4px;
    }
  }
}
</style>

